package cn.okcmd.myquartz.quartz.schedulers;

import cn.okcmd.myquartz.quartz.jobs.Task2WithOtherJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * create by caoqg on 2021/7/27
 * 功能说明:
 */
@Configuration
public class Task2Sch {

    @Bean("task2")
    public JobDetail detail() {
        JobDetail jobDetail = JobBuilder.newJob(Task2WithOtherJob.class)
                .withIdentity("task2", "task2group")
                .withDescription("task2detail").storeDurably().build();
        return jobDetail;
    }

    @Bean("t2t")
    public Trigger trigger() {
        CronScheduleBuilder cronSchedule = CronScheduleBuilder.cronSchedule("1/3 * * * * ?");
        CronTrigger trigger = TriggerBuilder.newTrigger()
                .forJob(detail())
                .withIdentity("task2", "task2group")
                .withDescription("task2tri")
                .withSchedule(cronSchedule).build();
        return trigger;
    }

}
